package jiang;

public class VolatileTest2 implements Runnable {
	int resource = 0;

	public static void main(String[] args) {
		VolatileTest2 vt = new VolatileTest2();
		new Thread(vt).start();
		new Thread(vt).start();
		while (Thread.activeCount() > 1) {
			Thread.yield();
		}
		System.out.println(vt.resource);
	}

	@Override
	public void run() {
		for (int i = 0; i < 1; i++) {
			int temp = resource;
			temp++;
			resource = temp;
			System.out.print("");
		}
	}
}
